class Header{
    constructor(container,loginContainer,registerContainer,page){
        this.container=container;
        this.loginContainer=loginContainer;
        this.registerContainer=registerContainer;
        this.page=page;
         //把init交给proxy去代理执行，并且把init内部的this指向变成当前this
        this.createDOM().then($.proxy(this.init,this));
    }
    //加载header的html
    createDOM(){
        return new Promise(resolve=>{
            this.container.load("/html/component/common/header.html",resolve);
        })
    }
    init(){
        new Login(this.loginContainer);
        new Register(this.registerContainer);
        //点击哪个页面,class发生改变
        this.nav();
    }
    nav(){
        let ali =$("#my-nav").children();
        if(this.page=="/"){
            ali.eq(0).addClass("active");
        }else if(this.page=="/list"){
            ali.eq(1).addClass("active");
        }
    }

}